﻿using OpenAdmin.Application.CachingServices;

namespace OpenAdmin.Application.Services;

/// <summary>
/// 商品相关服务
/// </summary>
public class ProductService : ServiceBase, IProductService, ITransientDependency
{
    private readonly IRepository<Product, MallDbContextLocator> _productRepository;
    private readonly IProductCacheService _productCacheService;
    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="productRepository"></param>
    /// <param name="productCacheService"></param>
    public ProductService(IRepository<Product, MallDbContextLocator> productRepository, IProductCacheService productCacheService)
    {
        _productRepository = productRepository;
        _productCacheService = productCacheService;
    }
    /// <summary>
    /// 分布获取商品列表
    /// </summary>
    /// <param name="requestDto"></param>
    /// <returns></returns>
    public Task<PagedList<ProductListByPageResponseDto>> ProductListByPageAsync(ProductListByPageRequestDto requestDto)
    {
        return default;
        //return await _productCacheService.ProductListByPageAsync("123", requestDto.PageIndex, requestDto.PageSize, async () =>
        // {
        //     var list = await _productRepository.Entities.AsQueryable()
        //        .Select(p => new ProductListByPageResponseDto
        //        {
        //            Name = p.Name,
        //            CreatedTime = p.CreateTime
        //        })
        //        .ToPagedListAsync(t => t.CreatedTime, requestDto.PageIndex, requestDto.PageSize);
        //     return list;
        // });
    }
}
